//
//  DelePhoneController.m
//  JianTingSwift
//
//  Created by zhibao on 2024/11/7.
//

#import "DelePhoneController.h"
#import "ChangePhoneController.h"
@interface DelePhoneController ()

@end

@implementation DelePhoneController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.bgImgView.hidden = NO;
    self.gk_navTitle = LocalizedString(@"注销账户");
    [self initView];
}

-(void)initView{
    
    UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 89 - 64 + NAVIH, 65, 65)];
    imgView.image = [UIImage imageNamed:@"me_set_out"];
    imgView.centerX = MY_Screen_W / 2;
    [self.view addSubview:imgView];
    
    UILabel *ctiplabel = [[UILabel alloc]initWithFrame:CGRectMake(25, imgView.bottom + 44, MY_Screen_W - 50, 22)];
    ctiplabel.text = LocalizedString(@"请谨慎操作！注销账号后：");
    ctiplabel.font = MY_SCALE_RegularFONT(14);
    ctiplabel.textColor = MyColor(@"#FD6301");
    [self.view addSubview:ctiplabel];
    
    YYLabel *ctip1label = [[YYLabel alloc]initWithFrame:CGRectMake(25, ctiplabel.bottom + 44, MY_Screen_W - 50, 200)];
    ctip1label.numberOfLines = 0;
    ctiplabel.lineBreakMode = NSLineBreakByWordWrapping;
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc]initWithString:LocalizedString(@".1、无法再登录账号；\n.2、注销账号无法撤销，无法恢复数据；\n.3、所有信息将立即依法合规删除。")];
    attri.yy_lineSpacing = 5;
    attri.yy_color = UIColor.whiteColor;
    attri.yy_font = MY_SCALE_RegularFONT(13);
    ctiplabel.preferredMaxLayoutWidth = MY_Screen_W - 50;
    ctip1label.attributedText = attri;
    [self.view addSubview:ctip1label];
    
    UIButton *nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    nextBtn.frame = CGRectMake(30, SafeSCREEN_HEIGHT - 15 - 40, MY_Screen_W - 60, 40);
    nextBtn.layer.cornerRadius = 20;
    nextBtn.backgroundColor = MYRed;
    [self.view addSubview:nextBtn];
    [nextBtn setTitle:LocalizedString(@"申请注销") forState:UIControlStateNormal];
    [nextBtn addTarget:self action:@selector(nextClick) forControlEvents:UIControlEventTouchUpInside];
    nextBtn.titleLabel.font = MY_SCALE_SemiboldFONT(15);
    [nextBtn setTitleColor:MyColor(@"ffffff") forState:UIControlStateNormal];
}

-(void)nextClick{
    [Helper alertShowWithTitle:LocalizedString(@"请谨慎操作！") withContent:LocalizedString(@"注销账号为不可逆操作，注销账号后你将无法再使用本账号找回你任何内容、信息和权益，也无权要求我们找回。") withSureBtnTitle:LocalizedString(@"取消") withCancelBtnTitle:LocalizedString(@"去注销") withSelect:^(NSInteger index) {
        if (index == 0) {
            //去注销
            [[HttpHelper sharedInstance] sendDelete:@"api/user/remove" parameters:@{}success:^(NSURLSessionTask * _Nonnull operation, ResponseModel * _Nonnull responseObject) {
                DLog(@"code===%@",responseObject.data);
                if (responseObject.code == 1) {
                    [[UserInfoManager sharedManager] initEmptyData];
                    [self.navigationController popToRootViewControllerAnimated:YES];
                }else{
                    [QMUITips showError:responseObject.message];
                }
                
            } failure:^(NSURLSessionTask * _Nonnull operation, NSError * _Nonnull error) {
                
            }];
        }else{
            //取消
        }
    }];
}

@end
